package com.lzw.controller.admin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzw.pojo.Bills;
import com.lzw.service.admin.BillsManage2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@CrossOrigin(origins = "http://localhost:7070")
@RestController
@RequestMapping("/BillsManage2")
public class BillsManage2 {

    @Autowired
    private BillsManage2Service billsManage2Service;

    @GetMapping("/list")
    public PageInfo<Bills> list(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate billDate,
            String medicine){
        PageHelper.startPage(pageNum,pageSize);
        List<Bills> list = billsManage2Service.list(pageNum, pageSize, medicine, billDate);
        return new PageInfo<>(list);
    }
}
